This article provides instructions on explicitly configuring your Ditto instance to listen for connections on a specific port and to connect to remote instances using a host (IP) and port.
Although Ditto automatically attempts to connect to other instances on the Local Area Network (LAN), Bluetooth Low Energy (LE), and Apple Wireless Direct Link (AWDL), supplying a DittoTransportConfig does not enable this feature by default.Rather, you manually enable peer-to-peer connections using EnableAllPeerToPeer(). (See Enabling and Disabling Transports)
// Create a new DittoTransportConfig()var config = DittoTransportConfig()//Enable all peer to peer transportsconfig.enableAllPeerToPeer()//Or enable/disable each transport separately//BluetoothLeconfig.peerToPeer.bluetoothLE.isEnabled = true//Local Area Networkconfig.peerToPeer.lan.isEnabled = true//Awdlconfig.peerToPeer.awdl.isEnabled = trueditto.transportConfig = configdo { try ditto.startSync()} catch (let err) { print(err.localizedDescription)}
// … continue with remaining sections following same pattern …